<template>
  <div class="viplogin">
    <ul id="spinners">
      <li class="active" data-id="1">
        <div class="left_log">
          <img src="../../img/viplogin.png" alt />
        </div>
        <div class="tit">正在带你进入佰联管理平台</div>

        <div class="loading">
          <div class="lef_tit">
            <!-- <div class="left_log">
              <span>佰联管理后台</span>
            </div>-->
            <!-- <span class="gg">|</span> -->
            <!-- <span>商户管理</span> -->
          </div>
          <div id="preloader_4">
            <span></span>
            <span></span>
            <span></span>
            <span></span>
            <span></span>
            <span>
              <a-icon type="right" class="rig_ico" />
            </span>
          </div>
          <!-- <div class="right_tit">
            <div class="left_log">
              <img src="../../img/viplogin.png" alt />
            </div>
            <span class="gg">|</span>
            <span>服务商平台</span>
          </div>-->
        </div>
      </li>
    </ul>
  </div>
</template>

<script>
import qs from "qs";
export default {
  inject: ["reload"],
  data() {
    return {
      //价格权限
      priceManage: {
        WLTEJIA_ok: 0,
        WLLSJ_ok: 0,
        WLPFJ_ok: 0,
        WLZDJ_ok: 0,
        PAIJIA_ok: 0
      }
    };
  },

  methods: {
    getloginsess() {
      this.axios
        .get("login/viplogin.php", { xhrFields: { withCredentials: true } })
        .then(res => {
          console.log(document.cookie);
          if (res.data.code == 303) {
            this.$store.state.token = res.data.token;
            sessionStorage.setItem("sqdwid", res.data.result.SQDWID);
            this.$store.state.bbl_sqdwid = res.data.result.SQDWID;
            this.$store.state.bbl_sub_mchid = res.data.result.sub_mchid;
            this.$store.state.bbl_phone = res.data.result.phone;
            sessionStorage.setItem("date_sess", new Date().getTime());
            sessionStorage.setItem("dwmc", res.data.result.dwmc);
            sessionStorage.setItem("wlkhjb", res.data.result.WLKHJB);
            sessionStorage.setItem("phone", res.data.result.phone);
            sessionStorage.setItem("tablefl", res.data.result.tablefl);
            sessionStorage.setItem(
              "language",
              JSON.stringify(res.data.result.language)
            );
            sessionStorage.setItem("bdwxnc", res.data.result.bdwxnc);
            sessionStorage.setItem("lxr ", res.data.result.tablefl);
            sessionStorage.setItem(
              "applymentstate",
              res.data.result.applyment_state
            );
            sessionStorage.setItem("sub_mchid", res.data.result.sub_mchid);
            for (var i = 0; i < res.data.result.power.length; i++) {
              res.data.result.power[i].menu_path = res.data.result.power[
                i
              ].menu_path.trim();
              this.$store.state.powerID.push(res.data.result.power[i].id_num);
            }
            sessionStorage.setItem(
              "powerID",
              JSON.stringify(this.$store.state.powerID)
            );

            sessionStorage.setItem(
              "power",
              JSON.stringify(res.data.result.power)
            );
            //存储价格权限--显示隐藏-字段--开始
            if (res.data.result.priceManage) {
              var priceManage_list = res.data.result.priceManage;
              if (priceManage_list.indexOf("WLTEJIA") != -1) {
                this.priceManage.WLTEJIA_ok = 1;
              }
              if (priceManage_list.indexOf("WLLSJ") != -1) {
                this.priceManage.WLLSJ_ok = 1;
              }
              if (priceManage_list.indexOf("WLPFJ") != -1) {
                this.priceManage.WLPFJ_ok = 1;
              }
              if (priceManage_list.indexOf("WLZDJ") != -1) {
                this.priceManage.WLZDJ_ok = 1;
              }
              if (priceManage_list.indexOf("PAIJIA") != -1) {
                this.priceManage.PAIJIA_ok = 1;
              }
            }
            sessionStorage.setItem(
              "priceManage",
              JSON.stringify(this.priceManage)
            );
            //存储价格权限--显示隐藏-字段--结束
            let power = res.data.result.power;
            this.$store.commit("getpower", power);
            let page = this.$route.query.page;
            console.log(page);
            if (page) {
              setTimeout(() => {
                this.$router.push("/" + page);
              }, 1000);
            } else {
              setTimeout(() => {
                this.$router.push("/");
              }, 1000);
            }
            // this.reload()
          } else {
            // location.href="/"

            setTimeout(() => {
              this.$router.push("/login");
            }, 1000);
          }
        });
    }
  },

  created() {
    this.getloginsess();
  }
};
</script>
	<style lang='less' scoped>
.viplogin {
  position: relative;
  z-index: 999;
  background-color: #fff;
  width: 100%;
  min-height: 1000px;
  text-align: center;
  display: flex;
  align-items: center;
  box-shadow: 0 3px 4px rgba(0, 0, 0, 0.1);
  .tit {
    font-size: 18px;
    font-weight: bold;
  }
  .left_log {
    display: inline-block;
    img {
      width: 140px;
      margin: 20px;
    }
  }
  .loading {
    position: relative;
    .lef_tit {
      position: absolute;
      left: -47%;
      color: #000;
      top: 53px;
      font-size: 16px;

      .gg {
        margin: 0 10px;
        color: #ccc;
      }
    }
    .right_tit {
      position: absolute;
      right: -55%;
      color: #000;
      top: 53px;
      font-size: 16px;
      .left_log {
        display: inline-block;
        img {
          width: 100px;
          margin-right: 20px;
        }
      }
      .gg {
        margin: 0 10px;
        color: #ccc;
      }
    }
  }
}
#spinners {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
}

#spinners li {
}

#spinners li.active {
  -webkit-transform: translateX(0);
  -moz-transform: translateX(0);
  -ms-transform: translateX(0);
  transform: translateX(0);
  opacity: 1;
}

/******************* PRELOADER 4 **********
*******************************************/

#preloader_4 {
  position: relative;
  top: 60px;
  left: 9%;
}
#preloader_4 span {
  position: absolute;
  width: 20px;
  height: 20px;
  left: 0;
  background: #3498db;
  opacity: 0.5;
  border-radius: 40px 0px 40px 0;
  -webkit-animation: preloader_4 1s infinite ease-in-out;
  -moz-animation: preloader_4 1s infinite ease-in-out;
  -ms-animation: preloader_4 1s infinite ease-in-out;
  -animation: preloader_4 1s infinite ease-in-out;
}
#preloader_4 span .rig_ico {
  color: #fff;
  font-size: 15px;
  vertical-align: middle;
  line-height: 34px;
}
#preloader_4 span:nth-child(2) {
  left: 30px;
  -webkit-animation-delay: 0.2s;
  -moz-animation-delay: 0.2s;
  -ms-animation-delay: 0.2s;
  animation-delay: 0.2s;
}
#preloader_4 span:nth-child(3) {
  left: 60px;
  -webkit-animation-delay: 0.4s;
  -moz-animation-delay: 0.4s;
  -ms-animation-delay: 0.4s;
  animation-delay: 0.4s;
}
#preloader_4 span:nth-child(4) {
  left: 90px;
  -webkit-animation-delay: 0.6s;
  -moz-animation-delay: 0.6s;
  -ms-animation-delay: 0.6s;
  animation-delay: 0.6s;
}
#preloader_4 span:nth-child(5) {
  left: 120px;
  -webkit-animation-delay: 0.8s;
  -moz-animation-delay: 0.8s;
  -ms-animation-delay: 0.8s;
  animation-delay: 0.8s;
}
#preloader_4 span:nth-child(6) {
  left: 150px;
  // background: transparent !important;
  border-radius: 20px;
  width: 30px;
  height: 30px;
}
@-webkit-keyframes preloader_4 {
  0% {
    opacity: 0.3;
    -webkit-transform: translateY(0px);
    box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.1);
  }
  50% {
    opacity: 1;
    -webkit-transform: translateY(-10px);
    background: #f1c40f;
    box-shadow: 0px 20px 3px rgba(0, 0, 0, 0.05);
  }
  100% {
    opacity: 0.3;
    -webkit-transform: translateY(0px);
    box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.1);
  }
}
@-moz-keyframes preloader_4 {
  0% {
    opacity: 0.3;
    -moz-transform: translateY(0px);
    box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.1);
  }
  50% {
    opacity: 1;
    -moz-transform: translateY(-10px);
    background: #f1c40f;
    box-shadow: 0px 20px 3px rgba(0, 0, 0, 0.05);
  }
  100% {
    opacity: 0.3;
    -moz-transform: translateY(0px);
    box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.1);
  }
}
@-ms-keyframes preloader_4 {
  0% {
    opacity: 0.3;
    -ms-transform: translateY(0px);
    box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.1);
  }
  50% {
    opacity: 1;
    -ms-transform: translateY(-10px);
    background: #f1c40f;
    box-shadow: 0px 20px 3px rgba(0, 0, 0, 0.05);
  }
  100% {
    opacity: 0.3;
    -ms-transform: translateY(0px);
    box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.1);
  }
}
@keyframes preloader_4 {
  0% {
    opacity: 0.3;
    transform: translateY(0px);
    box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.1);
  }
  50% {
    opacity: 1;
    transform: translateY(-10px);
    background: #f1c40f;
    box-shadow: 0px 20px 3px rgba(0, 0, 0, 0.05);
  }
  100% {
    opacity: 0.3;
    transform: translateY(0px);
    box-shadow: 0px 0px 3px rgba(0, 0, 0, 0.1);
  }
}
</style>
